﻿using PMIS.Shared.DTO;

namespace PMIS.Common
{
    public class ViewModelBase : BindableBase, INavigationAware
    {
        private string? _title = "";
        public string? Title
        {
            get
            {
                return _title;
            }
            set
            {
                SetProperty(ref _title, value);
            }
        }

        public virtual bool IsNavigationTarget(NavigationContext navigationContext)
        {
            return true;
        }

        public virtual void OnNavigatedFrom(NavigationContext navigationContext)
        {

        }

        public virtual void OnNavigatedTo(NavigationContext navigationContext)
        {
            MenuDto menu;
            if (navigationContext.Parameters.TryGetValue("menu", out menu))
            {
                this.Title = menu.Name;
            }
        }
    }
}
